#ifndef prs_AttrMessage_H
#define prs_AttrMessage_H

#include "svl.h"

namespace prs {

///////////////////////////////////////////////////////////////////////////////

struct IBaseReceiver : public svl::TPointer
{
  virtual ~IBaseReceiver() {}
};

///////////////////////////////////////////////////////////////////////////////

template <class T> struct IReceiver : virtual public IBaseReceiver
{
  virtual void Receive(T &Message) = 0;
};

///////////////////////////////////////////////////////////////////////////////

template <class T> static void SendMessage(T &Message,IBaseReceiver *Receiver)
{
  if (IReceiver<T> *Ptr = dynamic_cast<IReceiver<T>*>(Receiver)) {
    Ptr->Receive(Message);
  }
}

/****************************
///////////////////////////////////////////////////////////////////////////////

struct IMessage
{
  virtual ~IMessage() {}
  virtual void Send(IBaseReceiver *Receiver) { Except("Send");}

protected:
  template <class T> static void ConcreteSend(T &Message,IBaseReceiver *Receiver)
  {
    if (IReceiver<T> *Ptr = dynamic_cast<IReceiver<T>*>(Receiver)) {
      Ptr->Receive(Message);
    }
  }
  
private:
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////

#define DECLARE_ClientMessage() \
  virtual void Send(prs::IBaseReceiver *Receiver) { \
    ConcreteSend(*this,Receiver); \
  }
************************************************/

///////////////////////////////////////////////////////////////////////////////
}

#endif
